import time

from loguru import logger

from ConfigFile.Varconfig import LogPath


class Log:

    def __new__(cls, *args, **kwargs):
        if not hasattr(cls,'instance'):
            cls.instance = super(Log, cls).__new__(cls)
        return cls.instance

    def __init__(self):
        tim = time.strftime('%Y-%m-%d_%H_%M_%S',time.localtime())
        logger.add(rotation='1 MB',sink=f"{LogPath}\\run_{tim}.log")

    def debug(self,message):
        logger.debug(message)

    def info(self,message):
        logger.info(message)

    def error(self,message):
        logger.error(message)

    def warning(self,message):
        logger.warning(message)

